package com.example.asus.yuejian_10.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.asus.yuejian_10.R;
import com.example.asus.yuejian_10.bean.UserOrder;
import com.example.asus.yuejian_10.bean.VideoList;
import com.squareup.picasso.Picasso;

import java.util.List;

import static com.example.asus.yuejian_10.Config.VIDEO_URL;

/**
 * Created by Wolfh on 2017/5/19.
 */

public class OrderAdapter extends BaseListAdapter {

    public OrderAdapter(Context context, List list) {
        super(context, list);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View ItemView = layoutInflater.inflate(R.layout.item_classlist,parent,false);

        OrderViewHolder viewHolder = new OrderViewHolder(ItemView);//定义显示部件

        return viewHolder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, int position, List data) {
        final UserOrder orderlist = (UserOrder) data.get(position);
        //final CCourse course = (CCourse) data.get(position);

        if(holder instanceof  OrderViewHolder){

            OrderViewHolder viewHolder = (OrderViewHolder) holder;
            if(orderlist!=null){
                viewHolder.order_name.setText(orderlist.getName());
                viewHolder.order_time.setText(orderlist.getUpdate_time());
                viewHolder.order_price.setText(orderlist.getPay());

                if(!orderlist.getThumb().equals("")){
                    Picasso.with(context)
                            .load(VIDEO_URL+orderlist.getThumb())
                            .into(viewHolder.order_pic);
                }
                else {
                    viewHolder.order_pic.setImageResource(R.drawable.diagonallayout_background);
                }
            }


          /*  viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(context, ClubActivity.class);
                    intent.putExtra("club",clublist);

                    context.startActivity(intent);
                }

            });*/

        }

    }
}
